/**
 * 测试生成 import React, {render as h, help} from 'react'这种
 */
import * as types from '@babel/types'

import generate from '@babel/generator'

let t1 = types.program(
  [
    types.importDeclaration(
      [
        // 创建默认导入
        types.importDefaultSpecifier(types.identifier('React')),

        // 创建具名导入
        types.importSpecifier(
          // 别名
          types.identifier('h'),
          // 原始导入的名字
          types.identifier('render'),
        ),

        types.importSpecifier(
          types.identifier('help'),
          types.identifier('help')
        )
      ],
      types.stringLiteral('react')
    )
  ]
)

// 生成： import React, { render as h, help } from "react";
console.log(generate(t1).code);
